package cn.gong.jizhang.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.gong.jizhang.manager.ContextManager;
import cn.gong.jizhang.utils.DebugUtils;

public abstract class BaseAdap extends BaseAdapter {
	protected Context context;

	public BaseAdap() {
		this.context = ContextManager.getInstance().getContext();
	}

	public void destory() {

	}

	protected View inflate(int layoutID) {
		return LayoutInflater.from(context).inflate(layoutID, null);
	}

	protected void debug(int msg) {
		debug(String.valueOf(msg));
	}

	protected void debug(long msg) {
		debug(String.valueOf(msg));
	}

	protected void debug(String msg) {
		DebugUtils.debug(msg, getClass());
	}

	protected void debug(String name, int msg) {
		debug(name, String.valueOf(msg));
	}

	protected void debug(String name, long msg) {
		debug(name, String.valueOf(msg));
	}

	protected void debug(String name, String msg) {
		DebugUtils.debug(name + ":" + msg, getClass());
	}

	protected void debug(String tag, String name, String msg) {
		DebugUtils.debug(tag, name + ":" + msg, getClass());
	}

	protected void error(Throwable e) {
		DebugUtils.error(e);
	}

	protected void exception(Exception e) {
		DebugUtils.exception(e);
	}

	protected void isNull(String name, Object obj) {
		DebugUtils.isNull(name, obj, getClass());
	}

	protected LinearLayout findLinearLayoutById(int id, View view) {
		return (LinearLayout) view.findViewById(id);
	}

	protected Button findButtonById(int id, View view) {
		return (Button) view.findViewById(id);
	}

	protected ImageView findImageViewById(int id, View view) {
		return (ImageView) view.findViewById(id);
	}

	protected RelativeLayout findRelativeLayoutById(int id, View view) {
		return (RelativeLayout) view.findViewById(id);
	}

	protected TextView findTextViewById(int id, View view) {
		return (TextView) view.findViewById(id);
	}

	protected CheckBox findCheckBoxById(int id, View view) {
		return (CheckBox) view.findViewById(id);
	}

	protected ProgressBar findProgressBarById(int id, View view) {
		return (ProgressBar) view.findViewById(id);
	}

	protected FrameLayout findFrameLayoutById(int id, View view) {
		return (FrameLayout) view.findViewById(id);
	}
}
